package org.javaUtil.tool.readFile;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * read txt file by one line one line
 * @author muyi
 *
 */
public class ReadFile 
{
	
	
	
	/**
	 *  get txt file for list by  every line
	 * @param filePath  the file path
	 * @return list
	 * @throws IOException 
	 */
	public static List getTxtFile(String filePath) throws IOException 
	{
		FileInputStream fis=null;
		InputStreamReader read=null;
		BufferedReader br=null;
		List list=new ArrayList();
		  try {
		//input steam
			  fis=new FileInputStream(filePath);
		// utf-8
		 	read=new InputStreamReader(fis, "UTF-8");
		//BufferedReader
		 	br = new BufferedReader(read);
		 	String line=null;
			while((line=br.readLine())!=null)
			{
				list.add(line);
			}
		  } catch (Exception e)
		  {
			  e.printStackTrace();
		  }finally{
			  
		
		//close
			  if(br!=null){br.close();}
			  if(read!=null){read.close();}
			  if(fis!=null){	fis.close();}
	
		  }
		
		return list;
	}
	
	
}
